import 'package:flutter/material.dart';
import 'package:get/get.dart';

class ColorConstants {
  //颜色的常量值
  static const Color lightScaffoldBackgroundColor = Color(0xffF9F9F9); //整体背景颜色（Light）
  static const Color darkScaffoldBackgroundColor = Color(0xFF0F0F0F); //整体背景颜色（Dark）
  static const Color secondaryAppColor = Color(0xff00AFFF); //可以用作光标的一些颜色
  static const Color secondaryDarkAppColor = Color(0xFF1D1D1E); //Theme的Appbar颜色

  static const Color pageBg = Color(0xffF9F9F9);
  static const Color gray = Color(0xFFCCCCCC);
  static const Color lightGray = Color(0xffF6F6F6);
  static const Color black = Color(0xFF000000);
  static const Color white = Color(0xFFFFFFFF);
  static const Color dividerColor = Color(0xffd2d2d2);
  static const Color dividerA6 = Color(0x4da6a6a6);
  static const Color dividerItem = Color(0xffEDF0F3);
  static const Color dividerD9 = Color(0x4dd9d9d9);
  static const Color appBlue = Color(0xff0689fb);
  static const Color warningYellow = Color(0xffFF8A00);
  static const Color appRed = Color(0xffFF5E75);
  static const Color appGreen = Color(0xff28BE5D);
  static const Color redfe4093 = Color(0xffFE4049);
  static const Color grayf7f7fb = Color(0xffF7F7FB);
  static const Color grayd2 = Color(0xffD2D2D2);
  static const Color grayf4f6f8 = Color(0xFFF4F6F8);
  static const Color blue1578fe = Color(0xFF1578FE);
  static const Color employerText = Color(0xffA6BCFF);
  static const Color gray66 = Color(0xff666666);
  static const Color gray77 = Color(0xff777777);
  static const Color gray76 = Color(0xff767676);
  static const Color black43 = Color(0xff434343);
  static const Color black323843 = Color(0xff323843);
  static const Color grayf1 = Color(0xffF1F1F1);
  static const Color black33 = Color(0xff333333);
  static const Color black404A5B = Color(0xff404A5B);
  static const Color gray99 = Color(0xff999999);
  static const Color graye5 = Color(0xffE5E5E5);
  static const Color gray88 = Color(0xff888888);
  static const Color gray82 = Color(0xff828282);
  static const Color whitefe = Color(0xffFEFEFE);
  static const Color gray949cb4 = Color(0xff949CB4);
  static const Color blue4493fe = Color(0xff4493FE);
  static const Color blueecf4ff = Color(0xffECF4FF);
  static const Color green11b876 = Color(0xff11B876);
  static const Color grayeee = Color(0xffEEEEEE);
  static const Color greye0 = Color(0xffE0E0E0);
  static const Color tabTextBlue = Color(0xff00AFFF);
  static const Color tabTextBlack = Color(0xff373737);
  static const Color graySearchBg = Color(0xA50067B1);
  static const Color grayededed = Color(0xFFEDEDED);
  static const Color orangefb7746 = Color(0xFFFB7746);
  static const Color grayFullBg = Color(0xA5F9F9F9);
  static const Color whiteA5 = Color(0x40000000);
  static const Color orangeff9300 = Color(0xFFFF9300);
  static const Color blued5ebff = Color(0xFFD5EBFF);
  static const Color bluedc9cfe5 = Color(0xFFC9CFE5);
  static const Color bluede6f3ff = Color(0xFFE6F3FF);
  static const Color gary575757 = Color(0xFF575757);
  static const Color blue175285 = Color(0xFF175285);
  static const Color gray9B9B9B = Color(0xFF9B9B9B);
  static const Color gray9DF = Color(0xFFDFDFDF);

//黑暗模式的一些色值
  static const Color darkBlackBg = Color(0xFF0F0F0F);
  static const Color darkBlackItem = Color(0xFF1D1D1E);
  static const Color darkBlackItemLight = Color(0xFF3B3933);
  static const Color darkBlackItemLightMost = Color(0xFF5C5850);
  static const Color darkBlackItemDivider = Color(0xFF3B3B3F);

  // 颜色值转换
  static Color string2Color(String colorString) {
    int? value = 0x00000000;
    if (colorString.isNotEmpty) {
      if (colorString[0] == '#') {
        colorString = colorString.substring(1);
      }
      value = int.tryParse(colorString, radix: 16);
      if (value != null) {
        if (value < 0xFF000000) {
          value += 0xFF000000;
        }
      }
    }
    return Color(value!);
  }
}

Color hexToColor(String hex, {double opacity = 1.0}) {
  assert(RegExp(r'^#([0-9a-fA-F]{6})|([0-9a-fA-F]{8})$').hasMatch(hex), 'hex color must be #rrggbb or #rrggbbaa');

  return Color(
    int.parse(hex.substring(1), radix: 16) + (hex.length == 7 ? (opacity * 255).toInt() << 24 : 0x00000000),
  );
}
